<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <title>Title</title>
</head>
<body>
  <script>
    function asyncPrint (message) {
      console.log(message)
    }

    function pro1(message, miniSecond) {
      return new Promise((resolve, reject) => {
        setTimeout(asyncPrint, miniSecond, message)
      })
    }

    function pro2(message, miniSecond) {
      return new Promise((resolve, reject) => {
        // 注意下面的代码
        setTimeout(() => {
          asyncPrint(message);
          resolve(message)
        }, miniSecond)
      })
    }

    function pro3(message, miniSecond) {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve(message);
        }, miniSecond);
      }).then(res => {
        console.log(res);
        return res;
      })
    }

    function pro4(message, miniSecond) {
      return new Promise((resolve, reject) => {
        reject('1111');
      }).then(res => {
        console.log(res);
      })
    }

    async function result1() {
      console.log('before')
      await pro1('printMMEE', 1000)
      console.log('after')
      console.log('sync code')
    }

    async function result2() {
      console.log('before')
      await pro2('printMMEE', 1000)
      console.log('after')
      console.log('sync code')
    }

    async function result3() {
      console.log('before')
      await pro3('printMMEE', 1000)
      console.log('after')
      console.log('sync code')
    }

    async function result4() {
      console.log('before')
      await pro4('printMMEE', 1000)
      console.log('after')
      console.log('sync code')
    }

    result4();
  </script>
</body>
</html>
